/*
 *  Article.cpp
 *  Article
 *
 *  Created by Hamza SHAWY and Jonathan SCHRODER on 10/10/07.
 *  Copyright 2007 __MyCompanyName__. All rights reserved.
 *
 */




 #include "Reference.h"
 #include "Article.h"

 #include <iostream>
 #include <iomanip>
 
 using std::cout;
 using std::endl;



/* Definition of the default constructor  "Article" of the class "Article" */ 
    Article::Article( ) : Reference ( -1 , -1, "<undefined yet>" , "<undefined yet>"), 
    startPage (-1), endPage(-1), JournalInformations(" <undefined yet> ")
	{} // end Article default constructor

/* Definition of the regular constructor  "Article"  */     
	Article::Article(int id, int year, int sPage, int ePage, string author, string title,  string JournalInfos) : Reference ( id, year, author, title),
	startPage (sPage), endPage (ePage), JournalInformations (JournalInfos)
	{}// end Article regular constructor
															  
/*  Definition of the dedstructor  "~Article" of the class "Article"  */ 
    Article::~Article()    
	{} // end Article destructor	 

/*  Definition of the method "getStartPage" of the class "Article"  */    
    int Article::getStartPage() const
	  {
        return startPage ; // returns the start page
	  } // end function getStartPage
	  
/*  Definition of the method "getEndPage" of the class "Article"  */    
    int Article::getEndPage() const
	  {
        return endPage ; // returns the end page
	  } // end function getEndPage
	  
/*  Definition of the method "getNumberOfPages" of the class "Article"  */    
    int Article::getNumberOfPages() const
	  {
		if (startPage==-1 && endPage ==-1) return -1; 
		int NumberOfPages = ( getEndPage() - getStartPage() + 1 ); // returns the total number of pages (computed using starPage and endPage)
        cout << "                   --> Thus, the number of pages is equal to : ("<<getEndPage()<< " - "<<getStartPage()<< ") + 1 !"<<endl;
		return NumberOfPages;
	  } // end function getNumberOfPages			  	  	  
	  
/*  Definition of the method "getJournal" of the class "Article"	*/																																																																								  
	string Article::getJournal() const
	  {
        return JournalInformations ; // returns the name of the journal
	  } // end function getJournal	
	  	  

/*  Definition of the method "print" of the class "Article"	*/																																																																								  
	void Article::print()  //prints a string representation of this Article consisting of the id number, reference title, author and year of publication; 
	  {
        Reference :: print(); //  This member function overrides the one defined in the class Reference.
		cout << "         * The Article is also specified by its : "<< endl;
		cout <<  "						5) Journal informations, and those are : "<< getJournal()<<endl;
		cout <<  "						6) End Page which is : "<< getEndPage()<<endl;
		cout <<  "						7) Start Page which is : "<< getStartPage()<<endl;
		cout <<  "                      ---> So, the number of pages of this article is : "<< getNumberOfPages()<<endl;
	  } // end function print	 

	
/*  Definition of the member function "setIdentifier" of the class "Article" */     
    void Article::setStartPage( int sPage  )  // Sets the reference's identifier                
    {                                                           
       startPage = sPage ;                     
	} // end function setStartPage

/* Definition of the member function "setYearOfPublication" of the class "Article" */     
    void Article::setEndPage( int ePage  )  // Sets the reference's year of publication                  
    {                                                           
       endPage = ePage ;                     
	} // end function setEndPage 
	
/* Definition of the member function "setJournalInformations" of the class "Article" */     
    void Article::setJournalInformations( string JournalInfos )  // Sets the reference's author                  
    {                                                           
       JournalInformations = JournalInfos;                     
	} // end function setJournalInformations 
	
			
	
	
	
	
	